--- Introduction of the type class for 'http://en.wikipedia.org/wiki/Category_(mathematics) categories'.
protected package frege.control.Category 
        inline (F.id)
    where

import frege.prelude.PreludeBase 
import frege.control.Semigroupoid

--- The following type alias serves only to name the 'F.id' in the inline clause.
private type F = (->)

{--
    A category is a  'Semigroupoid' with the following additional properties:
    
    - For every object @A@, there exists a mophism @id(A): A -> A@ called the
    _identity morphism for A_, such that for every morphism @f: A -> B@ we have
    > id(B) • f = f = f • id(A)   
-}
class (Semigroupoid f) => Category f where
    --- the identity morphism
    id :: f a a

{--
    The category of Frege functions
-}
instance Category (->) where
    --- Identity on values
    --- @id x@ is @x@ 
    id = \x -> x